package photobox

class ManageFilters {

    def filters = {
        all(controller:'*', action:'*') {
            before = {
                if(controllerName.startsWith('mng')) {
                    if (session.user || actionName == "loginCheck" || actionName == "login") {
                        request.setAttribute('left_menu_id', params.left_menu_id ?  params.left_menu_id : 0)

                        return true
                    } else {
                        redirect(uri: "/mngHome/login")
                    }
                }else{
                    String path = request.getContextPath()
                    String domain_name = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"
                    request.setAttribute('domain_name', domain_name)
                }
            }
            after = { Map model ->

            }
            afterView = { Exception e ->

            }
        }
    }
}
